package cn.wolfcode.wechat.controller;

import cn.wolfcode.wechat.service.ILocationBlacklistService;
import cn.wolfcode.wechat.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MapController {
    @Autowired
    private ILocationBlacklistService locationBlacklistService;

    @RequestMapping("map")
    public String mapPage() {

        return "map";
    }

    @RequestMapping("about")
    public String about() {
        return "about";
    }

    @RequestMapping("checkLocation")
    @ResponseBody
    public JSONResult checkLocation(String keyword) {
        try {
            if (locationBlacklistService.findByKeyword(keyword)) {
                return new JSONResult();
            } else {
                return new JSONResult(false,"敏感地址,拒绝服务");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new JSONResult(false, e.getMessage());
        }
    }
}
